﻿using DataAccess.Services;
using System.Collections.Generic;
using System.Linq;

namespace BusinessLogic.Mappers.Currency
{
	class CurrencyMapper : MapperBase<BusinessEntity.Entities.Currency, DataControl.Currency>, ICurrencyMapper
	{
		public CurrencyMapper(IServiceManager serviceManager, IMapping<BusinessEntity.Entities.Currency, DataControl.Currency> mapping, IGatewayBase<DataControl.Currency> gatewayBase)
			: base(serviceManager, gatewayBase, mapping)
		{
		}

		public bool IsSupported(string currencyCode)
		{
			return ServiceManager.Currency.Exists(currencyCode);
		}


		public IList<BusinessEntity.Entities.Currency> GetSupportedCurrencies()
		{
			return ServiceManager.Currency.GetSupportedCurrencies().Select(currency => Mapping.ToBE(currency)).ToList();
		}

		public BusinessEntity.Entities.Currency GetByCode(string code)
		{
			return Mapping.ToBE(ServiceManager.Currency.GetByCode(code));
		}
	}
}
